<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试tpl.js</title>
</head>
<body>
    <div id="app"></div>
    <template id="tpl">
        {% let i = 0; %}
        {% for(let item of list){ %}
            <div class="list-item">${i} - ${item.name} - ${utils()}</div>
        {% i++; %}    
        {% } %}
    </template>
    <script src="./tpl.js"></script>
    <script>
        function utils() {
            return 'this is a utils function';
        };
        const app = document.querySelector('#app');
        const tpl = document.querySelector('#tpl');
        const render = tpljs(tpl.innerHTML);
        app.innerHTML = render({
            list: [
                { name: '入门指南' },
                { name: '组件库' },
                { name: '文档' },
            ]
        });
    </script>
</body>
</html>